<?php

require_once('db/db.php');

$db=new DB;

function check($name){
	if(isset($_REQUEST[$name])){
		return $_REQUEST[$name];
	}
	else{
		die();
	}
}

$desc=check('desc');
$father=check('father');

$sql = "insert into `category` (`father`,`desc`) values('$father','$desc')";

if(!$db->query($sql)){
	return false;
}

echo json_encode(array(
	'id' => mysql_insert_id(),
	'father' => $father,
	'desc' => $desc,
));

?>
